#!/usr/bin/python
# -*- coding: UTF8 -*-
import random
import codecs

class dataProject:
     title = []
     body = []
     tags = []
     url = []

     def setFileData(self, nameFile):

         dataFile = codecs.open('content/'+nameFile+'.txt' , 'r', 'utf-8')
         dataFileArray = dataFile.readlines()
         dataFile.close()

         return dataFileArray

     def addFixDataArray(self, nameMass, maxLine):

         while ( maxLine > len(nameMass) ):
             max = len(nameMass)
             nameMass += nameMass[random.randint(0, max-1)]
         return nameMass




     def generateDataProject(self):

         title = self.setFileData(nameFile='title')
         body = self.setFileData(nameFile='body')
         tags = self.setFileData(nameFile='tags')
         url = self.setFileData(nameFile='url')
         x = [len(title), len(body), len(tags), len(url)]

         maxLine = max(x)
         #print maxLine
         self.title = self.addFixDataArray(title, maxLine)
         self.body = self.addFixDataArray(body, maxLine)
         self.tags = self.addFixDataArray(tags, maxLine)
         self.url = self.addFixDataArray(url, maxLine)


         return 'ok'
     
#s = dataProject()
#print s.generateDataProject()
#print s.title[2]
#print len(s.title)

#print len(s.body)
#print len(s.tags)
#print len(s.url)




